<template>
  <div>
    <div class="back">
      <router-link to="/">
        <img :src="backSrc" style="width: 40px; height: 40px" alt="" />
      </router-link>
      <div class="text">新闻</div>
    </div>
    <div class="news">
      <div class="news_title">
        <h2>{{mes.title}}</h2>
      </div>
      <div class="news_base">
        <div class="news_author">作者:<b>{{mes.author}}</b></div>
        <div class="news_tips">
          <div class="news_status">{{mes.status}}</div>
          <div class="news_time">{{mes.time}}</div>
        </div>
      </div>
      <div class="news_content">
        <span>{{mes.content}}</span>
      </div>
    </div>
    <van-divider dashed>文章已经到底啦</van-divider>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      backSrc: require("../assets/images/back.png"),
      mes:{
        title:"清华本科生看不起武汉理工,得知其现状，明白原因话出有因",
        author:"搬运工",
        status:"搬运",
        time:"2022-11-5 09:36:06",
        content:"有一个摆在明面上的事,就是高校有着“985”和“211”、“双一流”与“双非”、—本和二本、本科和专科等之分。每一个希望到大学提升自己的人都应该想进入一所更好的学校，这是人之常情。"
      }
    };
  },
  methods: {
    getMes() {
      let id = this.$route.query;
      axios.post("http://127.0.0.1/list/checknews",id,{
          headers: "application/x-www-form-urlencoded",
        }).then((res) =>{
          console.log(res);
          let {data} = res;
          if(data.code == 200){
            let {rows} = data;
            this.mes.title = rows[0].title
            this.mes.author = rows[0].author
            this.mes.status = rows[0].status
            let time1 = rows[0].time.slice(0,10);
            let time2 = rows[0].time.slice(11,16);
            this.mes.time = time1 + " " + time2
            this.mes.content = rows[0].content
          } else if(data.code == -1){
            console.log("获取新闻失败");
          }
        })       
      console.log(id)
    },
  },
  mounted() {
    this.getMes();
  },
};
</script>

<style lang="less" scoped>
.back {
  width: 100%;
  height: 60px;
  position: fixed;
  top: 0;
  right: 0;
  background: linear-gradient(to left, #29eac4, #4284db);
  img {
    position: absolute;
    left: 0;
    top: 10px;
  }
  .text {
    text-align: center;
    line-height: 60px;
    height: 60px;
    box-sizing: border-box;
    border-bottom: 1px solid #ccc;
    font-weight: bold;
  }
}
.news {
  width: 95%;
  background-color: white;
  text-align: left;
  margin: 70px auto 0;
  border-radius: 4px;
  .news_title {
    padding-top: 6px;
    margin-left: 10px;
    margin-right: 10px;
    h2{
      margin-top: 0;
    }
  }
  .news_base{
    margin-left: 10px;
    .news_author{
      height: 30px;
      line-height: 30px;
    }
    .news_tips{
      display: flex;
      align-items: center;
      color: #888;
      font-size: 14px;
      .news_status{
        box-sizing: border-box;
        border: 1px solid #888;
        padding: 1px 4px;
        border-radius: 4px;
        font-size: 12px;
        margin-right: 8px;
      }
    }
  }
  .news_content{
    //文字默认排序
    // text-align: none !important;
    // display: flex;
    margin-top: 30px;
     margin-left: 10px;
    margin-right: 10px;
    font-size: 18px;
    line-height: 36px;
  }
}
</style>